package com.irdstudio.efp.esb.service.mock.zx;

import com.alibaba.fastjson.JSONObject;
import com.alibaba.fastjson.TypeReference;
import com.irdstudio.efp.esb.common.constant.ESBTradeNoConstance;
import com.irdstudio.efp.esb.service.bo.req.BaseZXReqBean;
import com.irdstudio.efp.esb.service.bo.req.NLMHitQueryReports;
import com.irdstudio.efp.esb.service.bo.resp.zx.BaseZXResBean;
import com.irdstudio.efp.esb.service.bo.resp.zx.NLMHitQueryResponseReports;
import com.irdstudio.efp.esb.service.vo.zx.ZXVO;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.context.annotation.DependsOn;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.List;
import java.util.function.Function;

/**
 * 需求编号:2020D0220
 * 名单系统40120008查询服务挡板
 *
 * @author F嘉阳
 * @date 2020/3/6 14:13
 */
@Service("zx11008Service")
@DependsOn("ZXConfig")
public class ZX11008ServiceImpl extends BaseZXService<NLMHitQueryReports, NLMHitQueryResponseReports> {

    private static Logger logger = LoggerFactory.getLogger(ZX11008ServiceImpl.class);

    @Override
    protected ZXVO postProcess(BaseZXReqBean<NLMHitQueryReports> reqBean, BaseZXResBean<NLMHitQueryResponseReports> resBean) throws Exception {
        logger.debug("名单系统查询进行后续处理，请求参数: " + reqBean + ", 返回结果： " + resBean);
        List<NLMHitQueryResponseReports> list = new ArrayList<>();
//        list.add(new NLMHitQueryResponseReports());
        NLMHitQueryResponseReports reports = new NLMHitQueryResponseReports();
        reports.setBlklistCustFlg("Y");
        reports.setHitInf("禁止类名单");
        reports.setPrcnt("100");
        reports.setHyprlnksAddr("超链接地址：http://itil.gzb.com/gzbitil/default.aspx?ReturnUrl=%2fgzbitil%2fNewOldMainPage%2fIndex.aspxdefault.aspx?ReturnUrl=%2fgzbitil%2fNewOldMainPage%2fIndex.aspxdefault.aspx?ReturnUrl=%2fgzbitil%2fNewOldMainPage%2fIndex.aspxdefault.aspx?ReturnUrl=%2fgzbitil%2fNewOldMainPage%2fIndex.aspxdefault.aspx?ReturnUrl=%2fgzbitil%2fNewOldMainPage%2fIndex.aspxdefault.aspx?ReturnUrl=%2fgzbitil%2fNewOldMainPage%2fIndex.aspxdefault.aspx?ReturnUrl=%2fgzbitil%2fNewOldMainPage%2fIndex.aspxdefault.aspx?ReturnUrl=%2fgzbitil%2fNewOldMainPage%2fIndex.aspxdefault.aspx?ReturnUrl=%2fgzbitil%2fNewOldMainPage%2fIndex.aspx");
        list.add(reports);
        return new ZXVO(Boolean.TRUE, list);
    }

    @Override
    protected String tradeNo() {
        return ESBTradeNoConstance.ZX11008;
    }

    @Override
    protected String scene() {
        return "04";
    }

    @Override
    protected Function<String, BaseZXResBean<NLMHitQueryResponseReports>> converter() {
        return i -> JSONObject.parseObject(i, new TypeReference<BaseZXResBean<NLMHitQueryResponseReports>>() {
        });
    }
}
